<?php
require("includes/basic.php");
$project=$_POST['project'];
$pro_desc=addslashes($_POST['project-desc']);
$creator=$userId;
$client=$_POST['client'];
$projectid=$_POST['projectid'];
$sql1=mysql_query("update project_master set project_name='$project', project_description='$pro_desc', project_modified_on=sysdate(), project_modified_by='$creator' where project_id=$projectid");
if($sql1)
{	
	$proid=$projectid;
	if(isset($_POST['submit']) && $_FILES['uploadedfile']['size'] > 0)
		{
			$fileName = $_FILES['uploadedfile']['name'];
			$tmpName = $_FILES['uploadedfile']['tmp_name'];
			$fileSize = $_FILES['uploadedfile']['size'];
			$fileType = $_FILES['uploadedfile']['type'];
			$fp      = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			$query = "INSERT INTO project_doc (name, size, type, content, project_id, uploaded_on, uploaded_by) VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$proid', sysdate( ), '$creator')";
			mysql_query($query) or die('Error, query failed'); 
			$filePath = $target_path . $fileName;
		}		
		if(isset($_POST['submit']) && $_FILES['file']['size'] > 0)
		{
			$fileName1 = $_FILES['file']['name'];
			$tmpName1 = $_FILES['file']['tmp_name'];
			$fileSize1 = $_FILES['file']['size'];
			$fileType1 = $_FILES['file']['type'];
			$fp1      = fopen($tmpName1, 'r');
			$content1 = fread($fp, filesize($tmpName1));
			$content1 = addslashes($content1);
			fclose($fp1);
			if(!get_magic_quotes_gpc())
			{
				$fileName1 = addslashes($fileName1);
			}
			$query = "INSERT INTO project_doc (name, size, type, content, project_id, uploaded_on, uploaded_by) VALUES ('$fileName1', '$fileSize1', '$fileType1', '$content1', '$proid', sysdate(), '$creator')";
			mysql_query($query) or die('Error, query failed'); 
			$filePath = $target_path . $fileName;
		}
if(isset($_POST['submit']) && $_FILES['file2']['size'] > 0)
		{
			$fileName2 = $_FILES['file2']['name'];
			$tmpName2 = $_FILES['file2']['tmp_name'];
			$fileSize2 = $_FILES['file2']['size'];
			$fileType2 = $_FILES['file2']['type'];
			$fp2      = fopen($tmpName2, 'r');
			$content2 = fread($fp2, filesize($tmpName2));
			$content2 = addslashes($content2);
			fclose($fp2);
			if(!get_magic_quotes_gpc())
			{
				$fileName2 = addslashes($fileName2);
			}
			$query = "INSERT INTO project_doc (name, size, type, content, project_id, uploaded_on, uploaded_by) VALUES ('$fileName2', '$fileSize2', '$fileType2', '$content2', '$proid', sysdate(), '$creator')";
			mysql_query($query) or die('Error, query failed'); 
			$filePath = $target_path . $fileName;
		}
if(isset($_POST['submit']) && $_FILES['file3']['size'] > 0)
		{

			$fileName3 = $_FILES['file3']['name'];
			$tmpName3 = $_FILES['file3']['tmp_name'];
			$fileSize3 = $_FILES['file3']['size'];
			$fileType3 = $_FILES['file3']['type'];
			$fp3      = fopen($tmpName3, 'r');
			$content3 = fread($fp3, filesize($tmpName3));
			$content3 = addslashes($content3);
			fclose($fp3);
			if(!get_magic_quotes_gpc())
			{
				$fileName3 = addslashes($fileName3);
			}
			$query = "INSERT INTO project_doc (name, size, type, content, project_id, uploaded_on, uploaded_by) VALUES ('$fileName3', '$fileSize3', '$fileType3', '$content3', '$proid', sysdate(), '$creator')";
			mysql_query($query) or die('Error, query failed'); 
			$filePath = $target_path . $fileName;
		}
if(isset($_POST['submit']) && $_FILES['file4']['size'] > 0)
		{
			$fileName4 = $_FILES['file4']['name'];
			$tmpName4 = $_FILES['file4']['tmp_name'];
			$fileSize4 = $_FILES['file4']['size'];
			$fileType4 = $_FILES['file4']['type'];
			$fp4      = fopen($tmpName4, 'r');
			$content4 = fread($fp4, filesize($tmpName4));
			$content4 = addslashes($content4);
			fclose($fp4);
			if(!get_magic_quotes_gpc())
			{
				$fileName4 = addslashes($fileName4);
			}
			$query = "INSERT INTO project_doc (name, size, type, content, project_id, uploaded_on, uploaded_by) VALUES ('$fileName4', '$fileSize4', '$fileType4', '$content4', '$proid', sysdate(), '$creator')";
			mysql_query($query) or die('Error, query failed'); 
			$filePath = $target_path . $fileName;
		}
if(isset($_POST['submit']) && $_FILES['file5']['size'] > 0)
		{
			$fileName5 = $_FILES['file5']['name'];
			$tmpName5 = $_FILES['file5']['tmp_name'];
			$fileSize5 = $_FILES['file5']['size'];
			$fileType5 = $_FILES['file5']['type'];
			$fp5      = fopen($tmpName5, 'r');
			$content5 = fread($fp5, filesize($tmpName5));
			$content5 = addslashes($content5);
			fclose($fp5);
			if(!get_magic_quotes_gpc())
			{
				$fileName5 = addslashes($fileName5);
			}
			$query = "INSERT INTO project_doc (name, size, type, content, project_id, uploaded_on, uploaded_by) VALUES ('$fileName5', '$fileSize5', '$fileType5', '$content5', '$proid', sysdate(), '$creator')";
			mysql_query($query) or die('Error, query failed'); 
			$filePath = $target_path . $fileName;
		}
$sql=mysql_query("update client_project set `client_id`=$client where project_id=$projectid");
}
if($sql)
{
 header("location:view-projects.php");
}
?>